

export default class store {

  static setItem(key: string, value: any) {
    try {
      if (typeof (value) === 'object') {
        return localStorage.setItem(key, JSON.stringify(value))
      } else {
        return localStorage.setItem(key, value)
      }
    } catch (err) {
      throw Error('错了')
    }
  }

  static getItem(key: string) {
    try {
      return JSON.parse(localStorage.getItem(key))
    } catch (err) {
      return localStorage.getItem(key)
    }
  }

  removeItem(key: string) {
    localStorage.removeItem(key)
  }
  clear() {
    localStorage.clear()
  }
  // sessionStorage.setItem('key', JSON.stringify(info));
  // localStorage.setItem('key', JSON.stringify(info));
}
